/*    */ package com.lmpop.frame.util;
/*    */ 
/*    */ import java.util.Iterator;
/*    */ import java.util.List;
/*    */ import java.util.Map;
/*    */ import java.util.Map.Entry;
/*    */ import java.util.Set;
/*    */ import org.apache.commons.configuration.ConfigurationException;
/*    */ import org.apache.commons.configuration.PropertiesConfiguration;
/*    */ 
/*    */ public class PropertiesConfigUtil
/*    */ {
/*    */   private PropertiesConfiguration configuration;
/* 15 */   private String config_name = "";
/*    */ 
/*    */   public PropertiesConfigUtil() {
/* 18 */     init("config.properties");
/*    */   }
/*    */ 
/*    */   public PropertiesConfigUtil(String configName) {
/* 22 */     init(configName);
/*    */   }
/*    */ 
/*    */   public void init(String configName)
/*    */   {
/* 27 */     this.config_name = configName;
/* 28 */     this.configuration = new PropertiesConfiguration();
/* 29 */     this.configuration.setEncoding("UTF-8");
/*    */     try {
/* 31 */       this.configuration.load(configName);
/*    */     }
/*    */     catch (ConfigurationException e) {
/* 34 */       e.printStackTrace();
/*    */     }
/*    */   }
/*    */ 
/*    */   public void setProperty(String key, String value) {
/* 39 */     this.configuration.setProperty(key, value);
/*    */   }
/*    */ 
/*    */   public void setProperty(Map properties) {
/* 43 */     Set entrySet = null;
/* 44 */     if ((properties != null) && (properties.size() > 0)) {
/* 45 */       entrySet = properties.entrySet();
/* 46 */       Iterator iterator = entrySet.iterator();
/* 47 */       while (iterator.hasNext()) {
/* 48 */         Map.Entry entry = (Map.Entry)iterator.next();
/* 49 */         String key = (String)entry.getKey();
/* 50 */         String value = (String)entry.getValue();
/* 51 */         this.configuration.setProperty(key, value);
/*    */       }
/*    */     }
/*    */   }
/*    */ 
/*    */   public Iterator getKeys() {
/* 57 */     return this.configuration.getKeys();
/*    */   }
/*    */ 
/*    */   public String getProperty(String key) {
/* 61 */     return this.configuration.getString(key);
/*    */   }
/*    */ 
/*    */   public String[] getStringArray(String key) {
/* 65 */     return this.configuration.getStringArray(key);
/*    */   }
/*    */ 
/*    */   public List getList(String key) {
/* 69 */     return this.configuration.getList(key);
/*    */   }
/*    */ 
/*    */   public void save() {
/*    */     try {
/* 74 */       this.configuration.save(this.config_name);
/*    */     }
/*    */     catch (ConfigurationException e) {
/* 77 */       e.printStackTrace();
/*    */     }
/*    */   }
/*    */ 
/*    */   public static void main(String[] args)
/*    */   {
/* 87 */     PropertiesConfigUtil configuration = new PropertiesConfigUtil("config.properties");
/* 88 */     configuration.setProperty("reg_send_mail", "4");
/* 89 */     configuration.save();
/*    */   }
/*    */ }

/* Location:           F:\电商\commons-utils.jar
 * Qualified Name:     com.lmpop.frame.util.PropertiesConfigUtil
 * JD-Core Version:    0.6.0
 */